package containerleran;

import java.util.Arrays;
import java.util.Iterator;

public class GenericClass <E>{
	public final  int id ;
	private E[] str;
	int length;
	public GenericClass(int m,E [] s){
		id = m ;
		length = s.length;
		str = Arrays.copyOf(s, s.length);
	}
	public void doPrint(){
		System.out.println("the value of id is "+ id);	
	}
	public void getTheInputClassType(E e){
		System.out.println(e.getClass().getName());
	}
	public void setId(int i){
	//	id = i;//the final id can not be changed even in the class 
	}
	public  void  testE (E e){
		System.out.println(e.toString());
	}
//	public void 
	public Iterator<E> retIterator(){
		return new Iterator<E>(){

			int pointer = 0;
			@Override
			public boolean hasNext() {
				// TODO Auto-generated method stub
				return pointer <length;
			}

			@Override
			public E next() {
				// TODO Auto-generated method stub
				return hasNext()?str[pointer++]:null;
			}

			@Override
			public void remove() {
				// TODO Auto-generated method stub
				pointer ++;
			}
			
		};
	}
}
